<me:UIVRK x:Class="WPFExcelReport.TVR02"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:ucd="clr-namespace:ReflectionStudio.Controls;assembly=ReflectionStudio.Controls"     
                    xmlns:me="clr-namespace:WPFExcelReport" 
                  xmlns:Localization="clr-namespace:Localization;assembly=Localization"
                       xmlns:ex="clr-namespace:WPFExcelReport.Controls;assembly=ExControls"
                    xmlns:WF="clr-namespace:WPFExcelReport;assembly=TICC_WFEVENTS"  
                     xmlns:SD="clr-namespace:WPFExcelReport;assembly=TSDDAT"  
                    xmlns:KD="clr-namespace:WPFExcelReport;assembly=TKDSTAMM"  
                    xmlns:HR="clr-namespace:WPFExcelReport;assembly=THRSTAMM"  
                    xmlns:DR="clr-namespace:WPFExcelReport;assembly=TDRAUFTR" 
                    xmlns:ZA="clr-namespace:WPFExcelReport;assembly=TZABED"   
                    xmlns:VRP="clr-namespace:WPFExcelReport;assembly=TVRPOS" 
                    xmlns:VKP="clr-namespace:WPFExcelReport;assembly=TVKPOS"     
                    xmlns:ZB="clr-namespace:WPFExcelReport;assembly=TVKZUAB"    
                    xmlns:TXT="clr-namespace:WPFExcelReport;assembly=TTXTIND"   
                   xmlns:VVT="clr-namespace:WPFExcelReport;assembly=TVVTLIEF"
                    x:Name="TV"
                    Loaded="Window_Loaded"
     >
    <me:UIVRK.Resources>
        <CollectionViewSource  x:Key="vwMaster"/>       <CollectionViewSource  x:Key="vwDetail"/>
        <ucd:BoolToVisibilityConverter  x:Key="bv"/>
        <ucd:NOTBoolToVisibilityConverter x:Key="nbv"/>
        <ucd:NOTConverter  x:Key="not"/>
        <ucd:Divideby100 x:Key="d100"/>
        <ucd:PNumConverter  x:Key="pnum"/>
        <ucd:GB2312Convert8859P1  x:Key="gb2312"/>
    </me:UIVRK.Resources>
    <DockPanel IsEnabled="{Binding IsBusy,ElementName=TV,Converter={StaticResource not}}">
         
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="30"></RowDefinition>
                <RowDefinition Height="1*"></RowDefinition>
            </Grid.RowDefinitions>
            <StackPanel Grid.Row="0" Visibility="{Binding KDBLOCK,ElementName=cKD,Converter={StaticResource bv}}">
                <TextBlock  VerticalAlignment="Center" HorizontalAlignment="Center"
                             Foreground="Red"
                            Text="{Binding Source={Localization:Translate Word=客户的信用已经超出}}"
                       />
            </StackPanel>
            <Grid Grid.Row="1">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="1*"></RowDefinition>
                    <RowDefinition Height="2*"></RowDefinition>
                </Grid.RowDefinitions> 
                <Grid Grid.Row="0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="1*"/>
                    </Grid.ColumnDefinitions>
                    <StackPanel Grid.Column="0">
                        <WrapPanel  VerticalAlignment="Top">
                            <Grid Margin="10,0,0,0" VerticalAlignment="Top"  >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Button Click="DeleteCommand" Height="20" Margin="5,0,0,0" Width="24" >
                                    <Button.Background>
                                        <ImageBrush  ImageSource="/ImagePackage;component/Images/Remove.png" />
                                    </Button.Background>
                                </Button>
                            </Grid>
                            <WrapPanel VerticalAlignment="Top" >
                          
                                <Button Click="ResetSeq" Content="{Binding Source={Localization:Translate Word=重置}}"   Visibility="{Binding IsITX,Converter={StaticResource bv}}"/>
                                <Button Margin="10,0,0,0" Width="80" Content="{Binding Source={Localization:Translate Word=订单确认款}}" Click="VKKPaymentCommand" />
                                <Button Margin="10,0,0,0" Width="80" Content="{Binding Source={Localization:Translate Word=发货前款}}" Click="VVPaymentCommand" />
                                <Button Margin="10,0,0,0" Width="80" Content="{Binding Source={Localization:Translate Word=尾款}}" Click="RESTPaymentCommand" />
                                <Button Margin="10,0,0,0" Width="80" Content="{Binding Source={Localization:Translate Word=未开票}}" Click="QueryCommand" />
                                <Button Margin="10,0,0,0" Width="80" Content="{Binding Source={Localization:Translate Word=未支付}}" Click="OpenVRCommand" />
                                <Button Margin="10,0,0,0"  Content="{Binding Source={Localization:Translate Word=申请佣金}}" Click="CommissionCommand" />
                                <WF:TBTNEXE INFO="佣金支付" DLL="TVRPOS" CMD="CMVR" STWNW="MainWindow" IsInfo="True"/>
                                <Button Margin="10,0,0,0"  Content="{Binding Source={Localization:Translate Word=申请提成}}" Click="BonusCommand" /> 
                                <WF:TBTNEXE INFO="提成支付" DLL="TVRPOS" CMD="BNVR" STWNW="MainWindow" IsInfo="True"/>
                                 <Grid Margin="10,0,0,0" VerticalAlignment="Top" 
                               Visibility="{Binding IsEdit,ElementName=TV,Converter={StaticResource bv}}">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    </Grid.ColumnDefinitions>
                                    <Button   Click="SaveCommand" Height="20" Margin="5,0,0,0" Width="24" >
                                        <Button.Background>
                                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Save.png" />
                                        </Button.Background>
                                    </Button>
                                </Grid>
                            </WrapPanel>  
                        </WrapPanel>
                        <WrapPanel>
                            <CheckBox Content="{Binding Source={Localization:Translate Word=含已付}}" IsChecked="{Binding IsPaid,ElementName=TV}"/>
                            <KD:TSKD02 Grid.Column="0" MinWidth="100"  IsEdit="True"
                               Name="cKD02"
                               KEY="{Binding Path=KUNDNR,ElementName=TV}" />
                         
                            <Grid Margin="10,0,0,0" VerticalAlignment="Top"  >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <TextBlock FontSize="16"  Text="{Binding Source={Localization:Translate Word=发票号码}}"/>
                                <ex:TXT72 Grid.Column="1" FontSize="16"   IsAutoClear="True" CharacterCasing="Upper" 
                              Text="{Binding ART,ElementName=TV}" Width="180" />
                            </Grid>
                            <Grid Margin="10,0,0,0" VerticalAlignment="Top"  >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <TextBlock FontSize="16"  Text="{Binding Source={Localization:Translate Word=订单号}}"/>
                                <ex:TXT72 Grid.Column="1" FontSize="16" MaxLength="2"  IsAutoClear="True" CharacterCasing="Upper" 
                              Text="{Binding KRS,ElementName=TV}" Width="30" PRE="  " />
                                <ex:TXT72 Grid.Column="2" FontSize="16" Margin="5,0,0,0" MaxLength="6"  IsAutoClear="True" 
                                          PRE="000000"
                              Text="{Binding LFD,ElementName=TV}" KeyUp="AUF_Enter" Width="90" />
                            </Grid>
                            <Button   Click="QueryCommand" Height="20" Margin="5,0,0,0" Width="24" >
                                <Button.Background>
                                    <ImageBrush  ImageSource="/ImagePackage;component/Images/Search.png" />
                                </Button.Background>
                            </Button>
                        </WrapPanel>
                        <TextBlock Text="{Binding INFO,ElementName=cTxt}"/>
                    </StackPanel>
                    <me:TVR04 Grid.Column="1" x:Name="cVRK"
                        ORDERNUM="{Binding KEY,ElementName=TV}" IsAuto="False"
                        IsNew="{Binding IsNew,ElementName=TV}"
                        IsEdit="{Binding IsEdit,ElementName=TV}"
                        IsSaved="{Binding IsSaved,ElementName=TV}"
                        IsShowBottom="{Binding IsShowBottom,ElementName=TV}"
                        IsShowTop="{Binding IsShowTop,ElementName=TV}"
                        IsShowLeft="{Binding IsShowLeft,ElementName=TV}"
                        IsShowRight="{Binding IsShowRight,ElementName=TV}"  
               />

                </Grid>
                <Grid Grid.Row="1" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="1*"/>
                    </Grid.ColumnDefinitions>
                    <DataGrid  Grid.Column="0"
                   VerticalAlignment="Top"  
                   AutoGenerateColumns="False"
                   EnableRowVirtualization="False"
                   VerticalScrollBarVisibility="Auto"
                   HorizontalScrollBarVisibility="Auto"
                   HeadersVisibility="Column"  
                    ItemsSource="{Binding Source={StaticResource ResourceKey=vwMaster}}"  
                   IsSynchronizedWithCurrentItem="True"
                    x:Name="dlgMaster"  
                   RowDetailsVisibilityMode="Visible" Margin="0.2,0,0.4,0">
                        <DataGrid.Columns>
                            <DataGridCheckBoxColumn Width="40" Binding="{Binding Path=IsSelected,RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type DataGridRow}}}">
                                <DataGridCheckBoxColumn.HeaderTemplate>
                                    <DataTemplate>
                                        <CheckBox x:Name="ckbSelectedAll" Checked="ckbSelectedAll_Click" Unchecked="ckbSelectedAll_Unchecked"></CheckBox>
                                    </DataTemplate>
                                </DataGridCheckBoxColumn.HeaderTemplate>
                            </DataGridCheckBoxColumn>
                            <DataGridTextColumn Binding="{Binding Path=KDKUNDNA,Converter={StaticResource gb2312}}"  Header="{Binding Source={Localization:Translate Word=客户}}" Width="Auto" />
                            <DataGridTextColumn Binding="{Binding Path=VRKRENR, Converter={StaticResource ResourceKey=pnum}}"  Header="{Binding Source={Localization:Translate Word=发票}}" Width="Auto" />
                            <DataGridTextColumn Binding="{Binding Path=VRKZAHLBED}"  Header="{Binding Source={Localization:Translate Word=付款方式}}" Width="Auto" />
                            <DataGridTextColumn Binding="{Binding Path=VRPAUFKRS}"   Width="Auto" />
                            <DataGridTextColumn Binding="{Binding Path=VRPAUFLFD, Converter={StaticResource ResourceKey=pnum}}"   Header="{Binding Source={Localization:Translate Word=销售单}}" Width="Auto" />
                            <DataGridTextColumn Binding="{Binding Path=VRKGESWERTN}"   Header="{Binding Source={Localization:Translate Word=发票金额}}" Width="Auto" />
                            <DataGridTextColumn Binding="{Binding Path=VRKWAWERT}"   Header="{Binding Source={Localization:Translate Word=货物价值}}" Width="Auto" />
                            <DataGridTextColumn Binding="{Binding Path=VRKZUAB}"   Header="{Binding Source={Localization:Translate Word=附加费}}" Width="Auto" />
                        </DataGrid.Columns>
                    </DataGrid  >
                    <VKP:TFVKP Grid.Column="1"
                 Name="cVKP"
                    FTAUTOSUM="True"
                   TKEY1="总数量"
                   SKEY1="VKPSA" 
                   KEY1="VKPMENGE1" 
                   TKEY2="总金额"
                   SKEY2="VKPSA" 
                   KEY2="VKPPOSWERT"
                 IsShowBottom="{Binding IsShowBottom,ElementName=TV}" 
                 ORDERNUM="{Binding VVKP,ElementName=TV}"/>
                </Grid>
                
                <TabControl Grid.Row="2">
                    <TabItem Header="{Binding Source={Localization:Translate Word=发票明细}}">
                        <VRP:TVR05 Grid.Row="2"
                 Name="cVRP"
                 Margin="10,0,0,0"
                 ARTST="F" 
                  FTAUTOSUM="True"
                  TKEY1="总数量"
                   SKEY1="VRPKOLL" 
                   KEY1="VRPMENGE" 
                   TKEY2="总金额"
                   SKEY2="VRPKOLL" 
                   KEY2="VRPGESWERT"
                  IsBlocked="{Binding IsInactive,ElementName=cVKP}"
                  IsCanPay="{Binding IsCanPay,ElementName=TV}"
                  IsShowRight="{Binding IsShowRight,ElementName=TV}"
                   IsShowBottom="{Binding IsShowBottom,ElementName=TV}"
                 KUNDNR="{Binding KUNDNR,ElementName=cVRK}" 
                 VKP="{Binding AUF,ElementName=cVKP}"
                 RENR="{Binding KEY,ElementName=cVRK}"
                 IsNew="{Binding IsNew,ElementName=TV}" 
                 IsFilterByVKP="True"  
                 />
                    </TabItem>
                    <TabItem Header="{Binding Source={Localization:Translate Word=客户信用}}">
                        <StackPanel>
                            <KD:TKD  Name="cKD"
                       ORDERNUM="{Binding KUNDNR,ElementName=cVRK}"  
                         KDBLOCK="{Binding KDBLOCK,ElementName=TV}"   
                         待处理现金="{Binding 待处理现金,ElementName=cVRP}"   
                         已付款="{Binding 已付款,ElementName=cVRP}"   
                         已开票="{Binding 已开票,ElementName=cVRP}"     
                         IsSaved="{Binding IsSaved,ElementName=cVRP}"
                         IsEdit="{Binding IsEdit,ElementName=cVRP}" 
                         />
                            <TXT:TXTITX Grid.Row="1"   Grid.Column="1"
                         Name="cTxt" 
                             TART="VKT"
                         IsAuto="False"
                         SIND="{Binding TXTISIND,ElementName=cVKP}"   
                        DEFTXT="{Binding DEFTXT,ElementName=cVKP}"  
                        />
                        </StackPanel>
                    </TabItem>
                    <TabItem Header="{Binding Source={Localization:Translate Word=销售单附加费}}">
                        <ZB:TVKZUAB Name="cZBP" Margin="10" IsAuto="True"  MaxHeight="300"  
                            VKZSA="VK"
                            ORDERNUM="{Binding AUF,ElementName=cVKP}"  />
                    </TabItem>
                    <TabItem Header="{Binding Source={Localization:Translate Word=发票说明}}"> 
                        <TXT:TXTITXBOX Grid.Row="1"   Grid.Column="1"
                        Name="cTxtK" 
                        IsAuto="False"
                        TART="VRK"
                        IsEdit="{Binding IsEdit,ElementName=cVRK}"
                        IsSaved="{Binding IsSaved,ElementName=cVRK}"
                        SIND="{Binding TXTISIND,ElementName=cVRK}"   
                        Width="Auto" HorizontalAlignment="Left"/>

                    </TabItem>
                    <TabItem Header="{Binding Source={Localization:Translate Word=付款方式}}">
                        <ZA:TZA03 Name="cZA03" ORDERNUM="{Binding ZAHLBED,ElementName=cVRK}" />

                    
                    </TabItem>
                    <TabItem Header="{Binding Source={Localization:Translate Word=发货信息}}" Name="cDEL">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="1*"></ColumnDefinition>
                                <ColumnDefinition Width="1*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <VVT:TVVTLIEF  Grid.Column="0"  Name="cVVT"  
                                 IsWBREQ="False"  
                                 IsAuto="False" 
                                           IsCanLoad="{Binding IsSelected,ElementName=cDEL}"
                                 VKP="{Binding AUF,ElementName=cVKP}"
                               /> 
                        </Grid>
                    </TabItem>
                </TabControl>
             
            </Grid>
        </Grid>

    </DockPanel>
</me:UIVRK>
